package com.example.swd1.gudong.main.sport.trainplan;

import android.content.Context;
import android.text.TextPaint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.swd1.gudong.R;
import com.example.swd1.gudong.model.MessageItem;

import java.util.List;


//==================================================================================================================
//   Author :  Shile Wu
//   Date  :  16-8-19
//   Role :    xx
//   Reference documents : xx
//==================================================================================================================
public class ChooseTrainPlanListViewAdapter extends BaseAdapter {
    private Context context;
    private int[] icon = new int[]{R.drawable.ic_medal_m_day1, R.drawable.ic_medal_m_run100, R.drawable.ic_medal_l_run5,
            R.drawable.ic_medal_l_run10, R.drawable.ic_medal_m_run100, R.drawable.ic_medal_l_run21};
    private String[] title = new String[]{"新手训练营","减肥燃脂","5k","10k","半程马拉松","马拉松"};

    public ChooseTrainPlanListViewAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return icon.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewHolder holder;
        if (convertView == null) {
            holder = new viewHolder();
            convertView = View.inflate(context, R.layout.item_plan_list, null);
            holder.titlePlan = (TextView) convertView.findViewById(R.id.title_plan);
            holder.iconPlan = (ImageView) convertView.findViewById(R.id.icon_plan);
            convertView.setTag(holder);

        } else {
            holder = (viewHolder) convertView.getTag();
        }
        holder.iconPlan.setImageResource(icon[position]);
        holder.titlePlan.setText(title[position]);

        return convertView;
    }

    private class viewHolder {
        ImageView iconPlan;
        TextView titlePlan;
    }
}
